home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / c / mnsbm.zip / MENUFORM.M < prev    next >
Text File  |  1989-10-31  |  1KB  |  45 lines

  1. ;**
  2. ;**    menuform.m:
  3. ;**
  4. ;**    An aid to pre-formatting menu files for use with the dialog manager.
  5. ;**    Type <F10>menuform<Enter>, and you will be prompted for the number
  6. ;**    of columns that will be visible in the finished menu window.  The
  7. ;**    text of the current buffer will be centered to fit.
  8. ;**
  9.  
  10. (macro menuform
  11.     (
  12.         (int        button_offset
  13.                     button_length
  14.                     width
  15.         )
  16.         (string    button
  17.                     text
  18.         )
  19.         (get_parm 0 width "Number of visible columns: ")
  20.         (tabs 2)
  21.         (top_of_buffer)
  22.  
  23.         (while (! (inq_position))
  24.             (
  25.                 (= button_offset (index (= button (trim (ltrim (read)))) ";"))
  26.                 (= text (ltrim (substr button (+ button_offset 1))))
  27.                 (= button (trim (substr button 1 (- button_offset 1))))
  28.                 (= button_length (strlen button))
  29.                 (= button_offset (+ (/ (- width button_length) 2) 1))
  30.  
  31.                 (delete_to_eol)
  32.                 (move_abs 0 button_offset)
  33.                 (insert button)
  34.                 (move_abs 0 (+ width 1))
  35.                 (insert (+ ";" text))
  36.                 (beginning_of_line)
  37.                 (down)
  38.             )
  39.         )
  40.         (top_of_buffer)
  41.         (translate "\t" " " 1)
  42.     )
  43. )
  44.  
  45.